import axios from 'axios'

axios.interceptors.request.use(config=>{
    // 配置公共路径
    config.baseURL = '/api'
    let token = localStorage.getItem('token')
    if(token){
        config.headers.token = token
    }
    return config
})

axios.interceptors.response.use(response =>{
    response = response.data
    if(response.code === 9){
        ROUTER.go(LOGIN)
        toastr.error(response.msg)
        return new Promise(()=>{})
    }
    return response
})

export default axios